#include <uitra.H>
#include <intrins.H>

sbit Tx =P1^0;
sbit RX =P1^1;




void Delay13us()		//@12.000MHz
{
	unsigned char i;

	_nop_();
	_nop_();
	i = 36;
	while (--i);
}


void uitar_int()
{

	unsigned char i;
	for(i=0;i<8;i++)
	{
	Tx = 1;
	Delay13us()	;
	Tx = 0;
	Delay13us()	;
	}

}

unsigned char ut_wave()
{
	unsigned int temp;
	CH = CL =0;
	CCON = 0;
	EA =0;
	uitar_int();
	EA =1;
	CR = 1;
	while((RX==1) && (CF==0));
	CR = 0;
	if(CF)
	{
		CF = 0;
		return 0;;
	}
	else
	{
		temp = (CH <<8) | CL;
		return (temp*0.017);
	}
	
}
